<?php

namespace App\Http\Models;

use Illuminate\Support\Facades\Redis;;

class CaseModel
{
    const REDIS_WEEK = "rank:pv:week";
    const REDIS_MONTH = "rank:pv:month";

    // 获取周排行
    public static function get_week_rank($pageno = 1, $pagesize = 9)
    {
        $redis = Redis::connection('db_main_slave');
        return $redis->zrevrange(self::REDIS_WEEK, ($pageno -1) * $pagesize, $pagesize * $pageno - 1, 'withscores');
    }

    // 获取月排行
    public static function get_month_rank($pageno = 1, $pagesize = 9)
    {
        $redis = Redis::connection('db_main_slave');
        return $redis->zrevrange(self::REDIS_MONTH, ($pageno -1) * $pagesize, $pagesize * $pageno - 1, 'withscores');
    }
}
